#include <vector>
#include <utility>
#include <string>
#include "article.h"
#include "dbinterface.h"
#include "dbmock.h"

using namespace std;

	/*
	Constructor
	*/
	dbmock::dbmock() {}

	/*	
	Destructor
	*/
	dbmock::~dbmock() {}

	/*
	Returns a vector of pairs of int and string. Contains three posts with first = {1111,22222,333333},
	second =  {"test 1", "test 2 2", "test 3 3 3"}.
	*/
	vector<pair<int, string>> dbmock::listnewsgroups() {
		vector<pair<int,string>> list;
		list.push_back(make_pair(1111, "test 1"));
		list.push_back(make_pair(22222, "test 2 2"));
		list.push_back(make_pair(333333, "test 3 3 3"));
		return list;
	}
	
	/*
	Returns true if name = "true", false otherwise
	*/
	bool dbmock::createnewsgroup(string name) {
		if(name == "true") {
			return true;
		} else {
			return false;
		}
	}
	
	/*
	Returns false if groupid = 0, true otherwise
	*/
	bool dbmock::deletenewsgroup(int groupid) {
		if(groupid == 0) {
			return false;
		} else {
			return true;
		}
	}

	/*
		Returns a vector with a pair(id, "test") if id != 0, an empty list otherwise
	*/
	vector<pair<int, string>> dbmock::listarticles(int id) {
		vector<pair<int, string>> list;
		if(id != 0) {
			list.push_back(make_pair(id, "test"));
		} 
		return list;

	}

	/*
	Returns false if groupid = 0, true otherwise
	*/
	bool dbmock::createarticle(int groupid, string title, string author, string text) {
		if(title == "" || author == "" || text == "")  {
			//Get rid of compiler warnings
		}
		if(groupid == 0) {
			return false;
		} else {
			return true;
		}
	}
	
	/*
	Returns 1 if groupid == 0, 2 if articleid == 0 (groupid != 0), 0 otherwise
	*/
	int dbmock::deletearticle(int groupid, int articleid) {
		if(groupid == 0) {
			return 1;
		} else if(articleid == 0) {
			return 2;
		} else {
			return 0;
		}
	}
	/*
	Returns pair(0, article(1,"title","author","text")) if groupid != 0 and articleid != 0, pair(1, ___) if groupid = 0,
	pair(2, ___) if articleid = 0;
	*/
	pair<int, article> dbmock::getarticle(int groupid, int articleid) {
		article a(1,"title","author","text");
		article b(0, "","","");
		if(groupid != 0 && articleid != 0) {
			return make_pair(0, a);
		} else if(groupid == 0) {
			return make_pair(1, b);
		} else {
			return make_pair(2, b);
		}
		
	}
